package com.file.system.entity.system;


import com.file.system.entity.basic.WebBasic;
import com.file.system.plugin.dict.Dict;
import com.file.system.plugin.validated.SQLInjectionValidation;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.*;
import javax.validation.groups.Default;
import java.io.Serializable;


/**
 * 系统文件
 *
 * @author jch
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class WebFile extends WebBasic implements Serializable {

    private static final long serialVersionUID = 1L;


    //新增
    public interface add extends Default {
    }

    //修改
    public interface update extends Default {
    }

    //上传文章文件
    public interface articleUpload extends Default {
    }

    public static WebFile init() {
        return new WebFile();
    }


    /**
     * 主键
     */
    @NotNull(groups = {update.class}, message = "主键不能为空")
    @Min(value = 1, message = "id长度最小1")
    private Long id;
    /**
     * 所属分类id
     */
    @NotNull(groups = {add.class, update.class, articleUpload.class}, message = "所属分类id不能为空")
    @Min(value = 1, message = "所属分类id最小1")
    private Long fkObjectId;
    /**
     * 文件名称
     */
    @NotEmpty(groups = {update.class, add.class}, message = "文件名称不能为空")
    @Size(min = 1, max = 500, message = "文件名称长度1-500")
    @SQLInjectionValidation(fieldName = "文件名称")
    private String name;

    /**
     * 文件原始名称
     */
    @Size(min = 1, max = 300, message = "原文件名称长度1-300")
    @SQLInjectionValidation(fieldName = "原文件名称")
    private String originalName;
    /**
     * 文件路径
     */
    @NotEmpty(groups = {update.class, add.class}, message = "文件路径不能为空")
    @Size(min = 1, max = 200, message = "文件路径长度1-200")
    @SQLInjectionValidation(fieldName = "文件路径", enableValidation = false)
    private String filePath;
    /**
     * 文件分组
     */
    @NotEmpty(groups = {update.class, add.class}, message = "文件分组不能为空")
    @Size(min = 1, max = 200, message = "文件分组长度1-200")
    @SQLInjectionValidation(fieldName = "文件分组")
    private String fileGroup;
    /**
     * 文件后缀
     */
    @NotEmpty(groups = {update.class, add.class}, message = "文件后缀不能为空")
    @Size(min = 1, max = 50, message = "文件后缀长度1-50")
    @SQLInjectionValidation(fieldName = "文件后缀")
    private String suffix;
    /**
     * 文件大小
     */
    @NotNull(groups = {add.class, update.class}, message = "文件大小不能为空")
    @Min(value = 1, message = "文件大小最小1")
    @SQLInjectionValidation(fieldName = "文件大小")
    private Long fileSize;
    /**
     * 排序
     */
    @NotNull(groups = {WebDictionaryVal.add.class, WebDictionaryVal.update.class}, message = "排序不能为空")
    @Min(value = 1, message = "排序最小1")
    @Max(value = 2000, message = "排序最大2000")
    private Integer sort;
    //------------------------------------------------------------------------------------------------------------
    /**
     * 栏目类型
     */
    @NotEmpty(groups = {articleUpload.class}, message = "栏目类型不能为空")
    @Size(min = 1, max = 20, message = "字典  栏目类型  文章 图片 文件  音频  视频  链接长度1-20")
    @Dict("articleType")
    @SQLInjectionValidation(fieldName = "栏目类型")
    private String dictArticleType;
    /**
     * 文件保存绝对地址
     */
    private String uploadPath;
    /**
     * 所属文件夹
     */
    private Long fkFolderId;
}
